package com.song.activiti.controller;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ActivitiController {
    @RequestMapping("start")
    public String start(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource("activities/test.bpmn20.xml")
                .addClasspathResource("activities/test.png")
                .name("测试流程")
                .deploy();
        System.out.println("流程id: " + deployment.getId());
        System.out.println("流程名称: " + deployment.getName());
        return "流程启动成功";
    }
}
